//
//  AppDelegate.m
//  jijianyemianzhiwu
//
//  Created by 王绵峰 on 2021/7/21.
//

#import "AppDelegate.h"
#import "weimeirenHomeViewController.h"
#import "FangSong.h"

@interface AppDelegate ()

@end


@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    UINavigationController * navgation = [[UINavigationController alloc]initWithRootViewController:  [[weimeirenHomeViewController alloc] initWithNibName:@"weimeirenHomeViewController" bundle:nil]];
                                          

    [navgation.navigationBar setBarTintColor:[UIColor colorWithRed:91.0f/255.0f green:189.0f/255.0f blue:34.0f/255.0f alpha:1]];
    
    [navgation.navigationBar setTintColor:[UIColor whiteColor]];
    
    [navgation.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor], NSFontAttributeName : [UIFont systemFontOfSize:17]}];
    
    [navgation.navigationBar setShadowImage:[UIImage new]];
    
    self.window.rootViewController = navgation;
    
    [[FangSong share] configParam:@{
      @"secret":@"887520015",

          @"wxKey":@"wx87ca82e6e98de18a",
          @"wxSec":@"3a601179f7413f86f58157be42213f92",

          @"qqKey":@"101871972",
          @"qqSec":@"cf5977471bb6a4f5600bc206b650300f",

          @"buApp":@"5197408",
          @"buAd":@"946415574",
          @"splashSlot":@"887520018",

            @"aliAuth":@"1mRXwBhB5SLAOT9ra2nvWgOHAm36Nus/W+wgwYxdvQwcHJYWmaAVEBeZj2mzuOy1CrkpxA0JsS/uaUMX6ruw95kQLRPgdijJlZ0s5lupHcMR99oPRHESsCbLB4sl4SP73dCL7i+8rLEYPIV6ASGCEl7zsnHKUnkAj2rsDHHR6Zbe2LJXo3S9vjXvPmimr/y5fP/8cLYm1Nz+OsuOGAFkaO7dj6RL9GG5I5aSMRIKi0Rho/S16vPxL+0mDbGxGM14ZRUUXBBdFB4=",

     } options:launchOptions];

    
    
    [self.window makeKeyAndVisible];
    
    return YES;
}



- (void)applicationDidBecomeActive:(UIApplication *)application {
    [[FangSong share] checkNet];
}

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
    [[FangSong share] handleOpenURL:url options:options];
    return YES;
}



#pragma mark - Core Data stack

@synthesize persistentContainer = _persistentContainer;

- (NSPersistentContainer *)persistentContainer {
    // The persistent container for the application. This implementation creates and returns a container, having loaded the store for the application to it.
    @synchronized (self) {
        if (_persistentContainer == nil) {
            _persistentContainer = [[NSPersistentContainer alloc] initWithName:@"botany"];
            [_persistentContainer loadPersistentStoresWithCompletionHandler:^(NSPersistentStoreDescription *storeDescription, NSError *error) {
                if (error != nil) {
                    // Replace this implementation with code to handle the error appropriately.
                    // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
                    
                    /*
                     Typical reasons for an error here include:
                     * The parent directory does not exist, cannot be created, or disallows writing.
                     * The persistent store is not accessible, due to permissions or data protection when the device is locked.
                     * The device is out of space.
                     * The store could not be migrated to the current model version.
                     Check the error message to determine what the actual problem was.
                    */
                    NSLog(@"Unresolved error %@, %@", error, error.userInfo);
                    abort();
                }
            }];
        }
    }
    
    return _persistentContainer;
}

#pragma mark - Core Data Saving support

- (void)saveContext {
    NSManagedObjectContext *context = self.persistentContainer.viewContext;
    NSError *error = nil;
    if ([context hasChanges] && ![context save:&error]) {
        // Replace this implementation with code to handle the error appropriately.
        // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
        NSLog(@"Unresolved error %@, %@", error, error.userInfo);
        abort();
    }
}

@end
